package com.nimbusung;

import com.nimbusung.domain.InProgress;
import com.nimbusung.domain.ListInProgress;
import com.nimbusung.domain.SimpleArrayAdapter;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class InProgressActivity extends Activity {
	
	private ImageView imageIcon;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.list_inprogress_layout);
		LinearLayout l = (LinearLayout) findViewById(R.id.mylayout1);
		LayoutInflater linflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		ListInProgress progList = new ListInProgress();
		
		for(InProgress linkInfo : progList.getList()){
			
			View customView = linflater.inflate(R.layout.inprogress_row, null);
			TextView link = (TextView) customView.findViewById(R.id.text_link);
			TextView church = (TextView) customView.findViewById(R.id.text_church);
			TextView event = (TextView) customView.findViewById(R.id.text_churchevent);
			
			imageIcon = (ImageView) customView.findViewById(R.id.imageWheater);
			setImage(linkInfo.getChurchName());
			
			link.setText(linkInfo.getLink());
			church.setText(linkInfo.getChurchName());
			event.setText(linkInfo.getEvent());
			
			link.setMovementMethod(LinkMovementMethod.getInstance());
			link.setClickable(true);
				
			//Add view
			l.addView(customView);
		}
		
	}
	
	private void setImage(String church){
		if(church.compareTo("NimbusUng") == 0){
		imageIcon.setImageResource(R.drawable.ung);
		}else{
		imageIcon.setImageResource(R.drawable.youth);
		}
	}


	/*
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		//get selected items
		String selectedValue = (String) getListAdapter().getItem(position);
		
		if(selectedValue.compareTo("Puls")==0){
			Intent pulsIntent; 
			pulsIntent = new Intent().setClass(this, NimbusPulsActivity.class); //Load the intent with information
	        this.startActivity(pulsIntent);
	    
		}
		
		Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();
	}
	*/


}
